package com.codeoss.framework.view.renderer;

import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.Tree;
import com.codeoss.framework.view.model.HierarchyData;

@Service
public class TreeRenderer extends CommonComponentRenderer {
	protected void startRenderView(YunContext yunContext, Component component, ViewSerializeMap viewSerializeMap) {
		super.startRenderView(yunContext, component, viewSerializeMap);
		Tree tree = (Tree) component;
		viewSerializeMap.put("checked", tree.isChecked());
		if(tree.getOnItemClickExpression()!=null) {
			viewSerializeMap.put("itemClickEvent", true);
		}
	}
	
	protected PropSerializeMap startRenderProp(YunContext yunContext,
			Component component, ViewPropMap viewPropMap) {
		PropSerializeMap propSerializeMap=super.startRenderProp(yunContext, component, viewPropMap);
		Tree tree = (Tree) component;
		HierarchyData root=(HierarchyData)yunContext.getAttribute(tree.getId()+"_data");
		propSerializeMap.put("data", root);
		return propSerializeMap;
	}
}
